<script setup>
import { ref } from 'vue'

const plantForm = ref({
  name: '',
  species: '',
  type: 'indoor',
  location: '',
  wateringFrequency: '',
  sunlight: 'medium',
  notes: '',
  image: null
})

const plantTypes = [
  { value: 'indoor', label: '室内植物' },
  { value: 'succulent', label: '多肉植物' },
  { value: 'flower', label: '观花植物' },
  { value: 'herb', label: '香草植物' }
]

const sunlightLevels = [
  { value: 'low', label: '低光照' },
  { value: 'medium', label: '中等光照' },
  { value: 'high', label: '强光照' }
]

const submitForm = () => {
  console.log('提交表单:', plantForm.value)
}
</script>

<template>
  <div class="add-plant">
    <h1 class="page-title">添加新植物</h1>
    
    <div class="form-container">
      <div class="image-upload">
        <div class="upload-area">
          <span class="upload-icon">🌿</span>
          <p>点击或拖拽上传植物图片</p>
        </div>
      </div>
      
      <form class="plant-form" @submit.prevent="submitForm">
        <div class="form-grid">
          <div class="form-group">
            <label>植物名称</label>
            <input 
              v-model="plantForm.name"
              type="text"
              placeholder="给你的植物起个名字"
            >
          </div>
          
          <div class="form-group">
            <label>物种名称</label>
            <input 
              v-model="plantForm.species"
              type="text"
              placeholder="例如：绿萝 (Epipremnum aureum)"
            >
          </div>
          
          <div class="form-group">
            <label>植物类型</label>
            <select v-model="plantForm.type">
              <option v-for="type in plantTypes" 
                      :key="type.value" 
                      :value="type.value">
                {{ type.label }}
              </option>
            </select>
          </div>
          
          <div class="form-group">
            <label>放置位置</label>
            <input 
              v-model="plantForm.location"
              type="text"
              placeholder="例如：客厅窗台"
            >
          </div>
          
          <div class="form-group">
            <label>浇水频率</label>
            <input 
              v-model="plantForm.wateringFrequency"
              type="text"
              placeholder="例如：每周两次"
            >
          </div>
          
          <div class="form-group">
            <label>光照需求</label>
            <select v-model="plantForm.sunlight">
              <option v-for="level in sunlightLevels" 
                      :key="level.value" 
                      :value="level.value">
                {{ level.label }}
              </option>
            </select>
          </div>
        </div>
        
        <div class="form-group full-width">
          <label>养护笔记</label>
          <textarea 
            v-model="plantForm.notes"
            placeholder="记录一些养护要点..."
            rows="4"
          ></textarea>
        </div>
        
        <div class="care-tips">
          <h3>🌟 快速养护指南</h3>
          <ul>
            <li>选择合适的光照环境</li>
            <li>控制浇水量，避免积水</li>
            <li>定期检查植物健康状况</li>
            <li>适时修剪，保持通风</li>
          </ul>
        </div>
        
        <button type="submit" class="submit-btn">
          <span>🌱</span>
          开始记录生长历程
        </button>
      </form>
    </div>
  </div>
</template>

<style scoped>
.add-plant {
  max-width: 1000px;
  margin: 0 auto;
}

.page-title {
  margin-bottom: 2rem;
  color: #2c3e50;
  font-size: 2rem;
}

.form-container {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
}

.image-upload {
  background: #f8faf7;
  border-radius: 12px;
  overflow: hidden;
}

.upload-area {
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #4CAF50;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-area:hover {
  background: #f1f8e9;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #2c3e50;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
  border-color: #4CAF50;
  outline: none;
}

textarea {
  resize: vertical;
}

.care-tips {
  grid-column: 1 / -1;
  background: #f1f8e9;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.care-tips h3 {
  color: #4CAF50;
  margin-bottom: 1rem;
}

.care-tips ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.care-tips li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.care-tips li::before {
  content: '•';
  color: #4CAF50;
  font-weight: bold;
}

.submit-btn {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.submit-btn:hover {
  background-color: #45a049;
}
</style> 